#include "mathlink.h"

#include <math.h>
#include <stdlib.h>
#include <stdio.h>


extern double FilterFunction( double omega, double t, double * seq, long seqLen);

double FilterFunction( double omega, double t, double * seq, long seqLen)
{
	double resRe, resIm, res2;
	int i, sign;

	resRe = 0.0; resIm = 0.0; sign = 1;
	for(i = 0; i < seqLen -1; i++)
	{
		resRe += ( cos(omega * t * seq[i+1] ) - cos(omega * t * seq[i] ) ) * sign;
		resIm += ( sin(omega * t * seq[i+1] ) - sin(omega * t * seq[i] ) ) * sign;
		sign *= -1;
	}
	res2 = resRe*resRe + resIm*resIm;	
	return res2;	
}



int main(int argc, char* argv[])
{
	return MLMain(argc, argv);
}

